package com.lagou.StageOne.Module4.Assignment.Assignment1;

import java.io.Serializable;

public class Student implements Serializable {


    private static final long serialVersionUID = -5603673748826911724L;
    private String name;
    private Integer age;
    private String sex;
    private Integer studentId;

    public Student() {
    }

    public Student(String name, Integer age, String sex, Integer studentId) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) throws StudentAgeException {
        if (age>0){
            this.age = age;
        }else {
                throw new StudentAgeException("该学生年龄不符合");
        }

    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getStudentId() {
        return studentId;
    }

    public void setStudentId(Integer studentId) throws StudentIdException {
        if (studentId>0){
            this.studentId = studentId;
        }else {
                throw new StudentIdException("该学生学号不符合");
        }

    }

    @Override
    public String toString() {
        return name+"  "+sex+"   "+age+"  "+studentId;
    }
}
